home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri K-CD 2002 #1 / K-CD_2002-01.iso / Delphi / INSTALL / program files / Borland / Delphi6 / Doc / OleCtrls.int < prev    next >
Encoding:
Text File  |  2001-05-22  |  12.8 KB  |  285 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Visual Component Library         }
  5. {                                                       }
  6. {  Copyright (c) 1996-2001 Borland Software Corporation }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit OleCtrls;
  11.  
  12. {$R-,T-,H+,X+}
  13. {$WARN SYMBOL_PLATFORM OFF}
  14.  
  15. interface
  16.  
  17. uses Variants, Windows, Messages, ActiveX, SysUtils, Classes, Controls, Forms,
  18.   Menus, Graphics, ComObj, AxCtrls;
  19.      
  20. var
  21.   { Hack: the compiler does not support default parameters for variant types. }
  22.   EmptyParam: OleVariant;
  23.  
  24. type
  25.  
  26.   TOleControl = class;
  27.  
  28.   TEventDispatch = class(TObject, IUnknown, IDispatch)
  29.   protected    
  30.     { IUnknown }
  31.     function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
  32.     function _AddRef: Integer; stdcall;
  33.     function _Release: Integer; stdcall;
  34.     { IDispatch }
  35.     function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
  36.     function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
  37.     function GetIDsOfNames(const IID: TGUID; Names: Pointer;
  38.       NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
  39.     function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
  40.       Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
  41.     property Control: TOleControl;
  42.   public
  43.     constructor Create(Control: TOleControl);
  44.   end;
  45.  
  46.   TOleEnum = ActiveX.TOleEnum;
  47.   {$NODEFINE TOleEnum}
  48.  
  49.   TEnumValue = record
  50.     Value: Longint;
  51.     Ident: string;
  52.   end;
  53.  
  54.   PEnumValueList = ^TEnumValueList;
  55.   TEnumValueList = array[0..32767] of TEnumValue;
  56.  
  57.   TEnumPropDesc = class
  58.   public
  59.     constructor Create(DispID, ValueCount: Integer;
  60.       const TypeInfo: ITypeInfo);
  61.     destructor Destroy; override;
  62.     procedure GetStrings(Proc: TGetStrProc);
  63.     function StringToValue(const S: string): Integer;
  64.     function ValueToString(V: Integer): string;
  65.   end;
  66.  
  67.   PControlData = ^TControlData;
  68.   TControlData = record
  69.     ClassID: TGUID;
  70.     EventIID: TGUID;
  71.     EventCount: Longint;
  72.     EventDispIDs: Pointer;
  73.     LicenseKey: Pointer;
  74.     Flags: DWORD;
  75.     Version: Integer;
  76.     FontCount: Integer;
  77.     FontIDs: PDispIDList;
  78.     PictureCount: Integer;
  79.     PictureIDs: PDispIDList;
  80.     Reserved: Integer;
  81.     InstanceCount: Integer;
  82.     EnumPropDescs: TList;
  83.   end;
  84.  
  85.   PControlData2 = ^TControlData2;
  86.   TControlData2 = record
  87.     ClassID: TGUID;
  88.     EventIID: TGUID;
  89.     EventCount: Longint;
  90.     EventDispIDs: Pointer;
  91.     LicenseKey: Pointer;
  92.     Flags: DWORD;
  93.     Version: Integer;
  94.     FontCount: Integer;
  95.     FontIDs: PDispIDList;
  96.     PictureCount: Integer;
  97.     PictureIDs: PDispIDList;
  98.     Reserved: Integer;
  99.     InstanceCount: Integer;
  100.     EnumPropDescs: TList;
  101.     FirstEventOfs: Cardinal;
  102.   end;
  103.  
  104.   TOleControl = class(TWinControl, IUnknown, IOleClientSite,
  105.     IOleControlSite, IOleInPlaceSite, IOleInPlaceFrame, IDispatch,
  106.     IPropertyNotifySink, ISimpleFrameSite)
  107.   protected
  108.     procedure StandardEvent(DispID: TDispID; var Params: TDispParams); virtual;
  109.     procedure InvokeEvent(DispID: TDispID; var Params: TDispParams); virtual;
  110.     { IUnknown }
  111.     function QueryInterface(const IID: TGUID; out Obj): HResult; override;
  112.     function _AddRef: Integer; stdcall;
  113.     function _Release: Integer; stdcall;
  114.     { IOleClientSite }
  115.     function SaveObject: HResult; stdcall;
  116.     function GetMoniker(dwAssign: Longint; dwWhichMoniker: Longint;
  117.       out mk: IMoniker): HResult; stdcall;
  118.     function GetContainer(out container: IOleContainer): HResult; stdcall;
  119.     function ShowObject: HResult; stdcall;
  120.     function OnShowWindow(fShow: BOOL): HResult; stdcall;
  121.     function RequestNewObjectLayout: HResult; stdcall;
  122.     { IOleControlSite }
  123.     function OnControlInfoChanged: HResult; stdcall;
  124.     function LockInPlaceActive(fLock: BOOL): HResult; stdcall;
  125.     function GetExtendedControl(out disp: IDispatch): HResult; stdcall;
  126.     function TransformCoords(var ptlHimetric: TPoint; var ptfContainer: TPointF;
  127.       flags: Longint): HResult; stdcall;
  128.     function IOleControlSite.TranslateAccelerator = OleControlSite_TranslateAccelerator;
  129.     function OleControlSite_TranslateAccelerator(msg: PMsg;
  130.       grfModifiers: Longint): HResult; stdcall;
  131.     function OnFocus(fGotFocus: BOOL): HResult; stdcall;
  132.     function ShowPropertyFrame: HResult; stdcall;
  133.     { IOleWindow }
  134.     function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall;
  135.     { IOleInPlaceSite }
  136.     function IOleInPlaceSite.GetWindow = OleInPlaceSite_GetWindow;
  137.     function OleInPlaceSite_GetWindow(out wnd: HWnd): HResult; stdcall;
  138.     function CanInPlaceActivate: HResult; stdcall;
  139.     function OnInPlaceActivate: HResult; stdcall;
  140.     function OnUIActivate: HResult; stdcall;
  141.     function GetWindowContext(out frame: IOleInPlaceFrame;
  142.       out doc: IOleInPlaceUIWindow; out rcPosRect: TRect;
  143.       out rcClipRect: TRect; out frameInfo: TOleInPlaceFrameInfo): HResult;
  144.       stdcall;
  145.     function Scroll(scrollExtent: TPoint): HResult; stdcall;
  146.     function OnUIDeactivate(fUndoable: BOOL): HResult; stdcall;
  147.     function OnInPlaceDeactivate: HResult; stdcall;
  148.     function DiscardUndoState: HResult; stdcall;
  149.     function DeactivateAndUndo: HResult; stdcall;
  150.     function OnPosRectChange(const rcPosRect: TRect): HResult; stdcall;
  151.     { IOleInPlaceUIWindow }
  152.     function GetBorder(out rectBorder: TRect): HResult; stdcall;
  153.     function RequestBorderSpace(const borderwidths: TRect): HResult; stdcall;
  154.     function SetBorderSpace(pborderwidths: PRect): HResult; stdcall;
  155.     function SetActiveObject(const activeObject: IOleInPlaceActiveObject;
  156.       pszObjName: POleStr): HResult; stdcall;
  157.     { IOleInPlaceFrame }
  158.     function IOleInPlaceFrame.GetWindow = OleInPlaceFrame_GetWindow;
  159.     function OleInPlaceFrame_GetWindow(out wnd: HWnd): HResult; stdcall;
  160.     function InsertMenus(hmenuShared: HMenu;
  161.       var menuWidths: TOleMenuGroupWidths): HResult; stdcall;
  162.     function SetMenu(hmenuShared: HMenu; holemenu: HMenu;
  163.       hwndActiveObject: HWnd): HResult; stdcall;
  164.     function RemoveMenus(hmenuShared: HMenu): HResult; stdcall;
  165.     function SetStatusText(pszStatusText: POleStr): HResult; stdcall;
  166.     function EnableModeless(fEnable: BOOL): HResult; stdcall;
  167.     function IOleInPlaceFrame.TranslateAccelerator = OleInPlaceFrame_TranslateAccelerator;
  168.     function OleInPlaceFrame_TranslateAccelerator(var msg: TMsg;
  169.       wID: Word): HResult; stdcall;
  170.     { IDispatch }
  171.     function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
  172.     function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
  173.     function GetIDsOfNames(const IID: TGUID; Names: Pointer;
  174.       NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
  175.     function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
  176.       Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
  177.     { ISimpleFrameSite }
  178.     function PreMessageFilter(wnd: HWnd; msg, wp, lp: Integer;
  179.       out res: Integer; out Cookie: Longint): HResult; stdcall;
  180.     function PostMessageFilter(wnd: HWnd; msg, wp, lp: Integer;
  181.       out res: Integer; Cookie: Longint): HResult; stdcall;
  182.     { TOleControl }
  183.     procedure CreateWnd; override;
  184.     procedure DefineProperties(Filer: TFiler); override;
  185.     procedure DestroyWindowHandle; override;
  186.     function GetByteProp(Index: Integer): Byte;
  187.     function GetColorProp(Index: Integer): TColor;
  188.     function GetTColorProp(Index: Integer): TColor;
  189.     function GetCompProp(Index: Integer): Comp;
  190.     function GetCurrencyProp(Index: Integer): Currency;
  191.     function GetDoubleProp(Index: Integer): Double;
  192.     function GetIDispatchProp(Index: Integer): IDispatch;
  193.     function GetIntegerProp(Index: Integer): Integer;
  194.     function GetIUnknownProp(Index: Integer): IUnknown;
  195.     function GetWordBoolProp(Index: Integer): WordBool;
  196.     function GetTDateTimeProp(Index: Integer): TDateTime;
  197.     function GetTFontProp(Index: Integer): TFont;
  198.     function GetOleBoolProp(Index: Integer): TOleBool;
  199.     function GetOleDateProp(Index: Integer): TOleDate;
  200.     function GetOleEnumProp(Index: Integer): TOleEnum;
  201.     function GetTOleEnumProp(Index: Integer): TOleEnum;
  202.     function GetOleVariantProp(Index: Integer): OleVariant;
  203.     function GetTPictureProp(Index: Integer): TPicture;
  204.     procedure GetProperty(Index: Integer; var Value: TVarData);
  205.     function GetShortIntProp(Index: Integer): ShortInt;
  206.     function GetSingleProp(Index: Integer): Single;
  207.     function GetSmallintProp(Index: Integer): Smallint;
  208.     function GetStringProp(Index: Integer): string;
  209.     function GetVariantProp(Index: Integer): Variant;
  210.     function GetWideStringProp(Index: Integer): WideString;
  211.     function GetWordProp(Index: Integer): Word;
  212.     procedure InitControlData; virtual; abstract;
  213.     procedure InitControlInterface(const Obj: IUnknown); virtual;
  214.     procedure InvokeMethod(const DispInfo; Result: Pointer);
  215.     function PaletteChanged(Foreground: Boolean): Boolean; override;
  216.     procedure PictureChanged(Sender: TObject);
  217.     procedure SetByteProp(Index: Integer; Value: Byte);
  218.     procedure SetColorProp(Index: Integer; Value: TColor);
  219.     procedure SetTColorProp(Index: Integer; Value: TColor);
  220.     procedure SetCompProp(Index: Integer; const Value: Comp);
  221.     procedure SetCurrencyProp(Index: Integer; const Value: Currency);
  222.     procedure SetDoubleProp(Index: Integer; const Value: Double);
  223.     procedure SetIDispatchProp(Index: Integer; const Value: IDispatch);
  224.     procedure SetIntegerProp(Index: Integer; Value: Integer);
  225.     procedure SetIUnknownProp(Index: Integer; const Value: IUnknown);
  226.     procedure SetName(const Value: TComponentName); override;
  227.     procedure SetWordBoolProp(Index: Integer; Value: WordBool);
  228.     procedure SetTDateTimeProp(Index: Integer; const Value: TDateTime);
  229.     procedure SetTFontProp(Index: Integer; Value: TFont);
  230.     procedure SetOleBoolProp(Index: Integer; Value: TOleBool);
  231.     procedure SetOleDateProp(Index: Integer; const Value: TOleDate);
  232.     procedure SetOleEnumProp(Index: Integer; Value: TOleEnum);
  233.     procedure SetTOleEnumProp(Index: Integer; Value: TOleEnum);
  234.     procedure SetOleVariantProp(Index: Integer; const Value: OleVariant);
  235.     procedure SetParent(AParent: TWinControl); override;
  236.     procedure SetTPictureProp(Index: Integer;  Value: TPicture);
  237.     procedure SetProperty(Index: Integer; const Value: TVarData);
  238.     procedure SetShortIntProp(Index: Integer; Value: Shortint);
  239.     procedure SetSingleProp(Index: Integer; const Value: Single);
  240.     procedure SetSmallintProp(Index: Integer; Value: Smallint);
  241.     procedure SetStringProp(Index: Integer; const Value: string);
  242.     procedure SetVariantProp(Index: Integer; const Value: Variant);
  243.     procedure SetWideStringProp(Index: Integer; const Value: WideString);
  244.     procedure SetWordProp(Index: Integer; Value: Word);
  245.     procedure _SetColorProp(Index: Integer; Value: TColor);
  246.     procedure _SetTColorProp(Index: Integer; Value: TColor);
  247.     procedure _SetTOleEnumProp(Index: Integer; Value: TOleEnum);
  248.     procedure _SetTFontProp(Index: Integer; Value: TFont);
  249.     procedure _SetTPictureProp(Index: Integer; Value: TPicture);
  250.     procedure WndProc(var Message: TMessage); override;
  251.     function SuppressException(E : Exception): Boolean; virtual;
  252.     property ControlData: PControlData;
  253.     { IPropertyNotifySink }
  254.     function OnChanged(dispid: TDispID): HResult; virtual; stdcall;
  255.     function OnRequestEdit(dispid: TDispID): HResult; virtual; stdcall;
  256.   public
  257.     constructor Create(AOwner: TComponent); override;
  258.     destructor Destroy; override;
  259.     procedure BrowseProperties;
  260.     procedure DefaultHandler(var Message); override;
  261.     procedure DoObjectVerb(Verb: Integer);
  262.     function GetEnumPropDesc(DispID: Integer): TEnumPropDesc;
  263.     function GetHelpContext(Member: string; var HelpCtx: Integer;
  264.       var HelpFile: string): Boolean;
  265.     procedure GetObjectVerbs(List: TStrings);
  266.     function GetPropDisplayString(DispID: Integer): string;
  267.     procedure GetPropDisplayStrings(DispID: Integer; List: TStrings);
  268.     function IsCustomProperty(DispID: Integer): Boolean;
  269.     function IsPropPageProperty(DispID: Integer): Boolean;
  270.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  271.     procedure SetPropDisplayString(DispID: Integer; const Value: string);
  272.     procedure ShowAboutBox;
  273.     property OleObject: Variant;
  274.     property PerPropBrowsing: IPerPropertyBrowsing;
  275.     property DefaultDispatch: IDispatch;
  276.     property TabStop default True;
  277.   end;
  278.  
  279.   EOleCtrlError = class(Exception);
  280.  
  281. function FontToOleFont(Font: TFont): Variant;
  282. procedure OleFontToFont(const OleFont: Variant; Font: TFont);
  283.  
  284. implementation
  285.